package com.lifeng.controller;

import com.lifeng.client.UserServiceFeignClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by lifeng on 2018/4/13.
 */
@RestController
public class UserConsumerController {
    @Autowired
    private UserServiceFeignClient userServiceFeignClient;

    @RequestMapping("/user/{id}")
    public Object getUser(@PathVariable String id){
        return userServiceFeignClient.findById(id);
    }

    @RequestMapping(value = "/user")
    public Object add(String id,String name){
        //return userServiceFeignClient.save(id,name);
        Map<String,Object> map = new HashMap<String,Object>();
        map.put("id",id);
        map.put("name",name);
        //return userServiceFeignClient.save1(map);
        return userServiceFeignClient.save(id,name);
    }
}
